package gov.goias.recad.persistencia;

import gov.goias.recad.dominio.Municipio;
import gov.goias.recad.excessao.InfraExcessao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.springframework.stereotype.Repository;

@Repository
public class MunicipioDAO{
	
	@PersistenceContext
	protected EntityManager persistencia;
	
	@SuppressWarnings("unchecked")
	public List<Municipio> listarPorUf(final String uf)throws InfraExcessao{
		final Query consulta =  persistencia.createNamedQuery("Municipio.listarPorUf");
		
		consulta.setParameter("uf", uf );
		
		return consulta.getResultList();
		
	}
	
}